<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<%@include file="../common/selfCss.jsp"%>
<script type="text/javascript" src="/thirdparty/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		$("#obtaintrForm").validate({
			errorClass:"validate_error",
			rules : {
				obtainDate : {required : true}
			},
			messages : {
				obtainDate : {required : "请指定抓取日期"}
			},
			submitHandler:function(form) {
				$(form).ajaxSubmit(function(data){
					if(data=="success"){
						alert("抓取完毕！");
					}else{
						alert("亲！系统有点抽筋，请稍候再试！");
					}
				});
			}
		});
	});

	var taobaokeReportGrid = null;
	$(function(){
		taobaokeReportGrid = $("#taobaoke_report_grid").ligerGrid({
				rownumbers : true,
	            columns: [
	    	    { display: '果果街会员ID', name: 'member', isSort : false, width: 100 },
	    	    { display: '果果街商品ID', name: 'guoguojieProductId',isSort : false, width: 100 },
	    	    { display: '果果街返现比率', name: 'guoguojieCommissionRate',isSort : false, width: 180},
	    	    { display: '果果街返现佣金', name: 'guoguojieCommission',isSort : false, width: 100 },
	    	    { display: '果果街是否返现', name: 'guoguojieRebate',isSort : false, width: 100,
                	render: function(record, rowindex, value, column){
                		if (value) {
                			return "是";
                		} else {
                			return "否"
                		}
	            	}
	            },
				{ display: '淘宝父交易号', name: 'tradeParentId', isSort : false, width: 98 },
				{ display: '淘宝交易号', name: 'tradeId', isSort : false, width: 98 },
				{ display: '实际支付金额', name: 'realPayFee', isSort : false, width: 75 },
				{ display: '佣金比率', name: 'commissionRate', isSort : false, width: 50 },
				{ display: '佣金', name: 'commission', isSort : false, width: 50 },
				{ display: '补贴比率', name: 'subsidyRate', isSort : false, width: 50 },
				{ display: '补贴金额', name: 'subsidy', isSort : false, width: 50 },
				{ display: '应用授权码', name: 'appKey', isSort : false, width: 70 },
				{ display: '推广渠道', name: 'outerCode', isSort : false, width: 90 },
				{ display: '订单创建时间', name: 'createTime', isSort : false, width: 100,
                	render: function(record, rowindex, value, column){
                		if (null != value && "" != value) {
                			return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                		} else {
                			return ""
                		}
	            	}
	            },
				{ display: '订单最终确认时间', name: 'confirmTime', isSort : false, width: 100,
                	render: function(record, rowindex, value, column){
                		if (null != value && "" != value) {
                			return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                		} else {
                			return ""
                		}
	            	}
	            },
				{ display: '订单状态', name: 'status', isSort : false, width: 100 },
				{ display: '成交时间', name: 'payTime', isSort : false, width: 100,
                	render: function(record, rowindex, value, column){
                		if (null != value && "" != value) {
                			return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                		} else {
                			return ""
                		}
	            	}
	            },
				{ display: '成交价格', name: 'payPrice', isSort : false, width: 50 },
				{ display: '商品ID', name: 'numIid', isSort : false, width: 90 },
				{ display: '商品标题', name: 'itemTitle', isSort : false, width: 100 },
				{ display: '商品成交数量', name: 'itemNum', isSort : false, width: 75 },
				{ display: '商品类目ID', name: 'categoryId', isSort : false, width: 70 },
				{ display: '商品类目名称', name: 'categoryName', isSort : false, width: 100 },
				{ display: '店铺名称', name: 'shopTitle', isSort : false, width: 100 },
				{ display: '卖家昵称', name: 'sellerNick', isSort : false, width: 100 }
	            ], 
	            pageSize:20,
	            root :'list',
	            record:'totalRecord',
	            url: "/misc/top/gettaobaokereport.htm",
	            width: '99%',height:'99%'
	        });
	
	});

	function filterTaobaokeReport(){
		var date = $("#date").val();
		taobaokeReportGrid.options.parms = [{name:'date',value:date}];
		taobaokeReportGrid.loadData();
  	}
	
</script>
<form action="/misc/top/obtaintr.htm" method="post" id="obtaintrForm">
<table width="100%" class="def_t" style="background:red">
	<tr>
		<td>
		日期：<input type="text" id="obtainDate"  readonly="readonly" name="obtainDate" onclick="WdatePicker({el:'obtainDate',dateFmt:'yyyyMMdd',readOnly:true});"/>
		</td>
		<td>
		<button onclick="obtainTaobaokeReport()">抓取淘宝客报表</button>
		</td>
		<td>
		<a href="http://container.api.taobao.com/container?appkey=21080975" target="_blank">登录到淘宝开放平台</a>
		</td>
	</tr>
</table>
</form>
<table width="100%" class="def_t">
	<tr>
		<%-- <td>
		日期：<input type="text" id="date"  readonly="readonly" name="date" onclick="WdatePicker({el:'date',dateFmt:'yyyyMMdd',readOnly:true});"/>
		</td>--%>
		<td>
		<button onclick="filterTaobaokeReport()">查看果果街报表</button>
		</td>
	</tr>
</table>
<div id="taobaoke_report_grid" style="margin:0; padding:0"></div>